# _*_ coding: utf-8 _*_
# @Time : 2024-01-24 11:40
# @Author : WF

# https://blog.csdn.net/qq_61260911/article/details/129885971
# 安装pyautogui ： pip install pyautogui
import time

from selenium import webdriver
import pyautogui
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.add_argument(argument='--headless')  # 设置无窗口模式
options.add_argument('--disable-gpu')  # 禁用gpu加速

driver_width, driver_height = pyautogui.size()  # 通过pyautogui方法获得屏幕尺寸
options.add_argument(argument='--window-size=%sx%s' % (driver_width, driver_height - 200))

# print(driver_width, driver_height)

driver = webdriver.Chrome(options=options)
# driver.get('https://www.jd.com/')
driver.get('https://www.baidu.com')

driver.find_element(By.NAME, 'wd').send_keys('我的世界\n')
time.sleep(5)

driver.save_screenshot('我的世界-1.png')

time.sleep(20)
driver.quit()
